package com.bj.zspace.project.reactor.netty.tcp;

import reactor.core.publisher.Mono;
import reactor.netty.DisposableServer;
import reactor.netty.tcp.TcpServer;

/**
 * TcpServer测试
 */
public class TcpServerTest {

    public static void main(String[] args) {
        TcpServer server = TcpServer.create();
        // 进行预热
        server.handle((in, out) -> out.send(in.receive()));

        server.warmup().block(); // 预热操作

        DisposableServer disposableServer1 = server.host("localhost")
                .port(8080)
                .bindNow();

        DisposableServer disposableServer2 = server.host("localhost")
                .port(8081)
                .bindNow();

        Mono.when(disposableServer1.onDispose(), disposableServer2.onDispose()).block();


    }

}
